<script setup lang="ts">
	import { onMounted, ref, watch,onUnmounted } from "vue";
	import {useRouter,useRoute} from 'vue-router';
	import { useWorkBenches, useWebstock } from '@/store';
	import zhCN from 'ant-design-vue/es/locale/zh_CN' 
	
	const locale = ref(zhCN);
	const ROUTER = useRouter();
	const Workben = useWorkBenches();
	
	const token = localStorage.getItem('token');
	
	// watch(()=>token,()=>{
	// 	if(token){
	// 		// console.log(token);
	// 	}else{
	// 		// console.log(ROUTER.currentRoute._rawValue.fullPath)
	// 		// if(ROUTER.currentRoute._rawValue.fullPath != '/'){
	// 		// 	ROUTER.replace({path: '/login'});
	// 		// }
	// 		console.log(2)
	// 	}
	// },{ immediate:true,deep:true });
	
	onMounted(()=>{
		if(token){
			useWebstock().connWebstock();
			Workben.getList(true);
		}
	});
	
	onUnmounted(()=>{
		useWebstock().webSocketClose();
	});
</script>

<template>
	<transition name="page-fade" mode="out-in">
		<a-config-provider :locale="locale">
			<router-view />
		</a-config-provider>
	</transition>
</template>
<style lang="less">
	
	// width: 100%;
	// height: 100%;
	// margin: 0;
	// padding: 0;
</style>
